from django import forms
from django.utils.safestring import mark_safe
from django.conf import settings
class RichText(forms.Textarea):
    class Media:
        css={
            '':('/static/ueditor/themes/default/ueditor.css',)
        }
        js=('/static/ueditor/editor_config.js','ueditor/editor_ui_all.js',)
   
    def render(self, name, value, attrs=None):
#        rendered = super(UEditerWidget, self).render(name, value, attrs)
        
        return mark_safe(u'''
            <div id="id_%s">

</div>
            <script type="text/javascript">
    var option = {
            initialContent: '%s',
            textarea: '%s',
            minFrameHeight:200,
            

        };
    var editor = new baidu.editor.ui.Editor(option);
    editor.render('id_%s');
</script>
            ''' % (name,value,name,name))
  